/*
 * RenderPlayerService.java
 * Description:
 * Author: zxt
 */

package com.zxt.dlna.dmr;

import com.zxt.dlna.dmp.GPlayer;
import com.zxt.dlna.dmp.ImageDisplay;
import com.zxt.dlna.util.Action;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

public class RenderPlayerService extends Service {

    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        int res = super.onStartCommand(intent, flags, startId);
        if (intent != null) {
            String type = intent.getStringExtra("type");
            Intent intent2;

            switch (type) {
                case "audio":
                    // new Thread(new RenderPlayerService.1(this,
                    // intent.getStringExtra("playURI"),
                    // intent.getStringExtra("name"))).start();
                    intent2 = new Intent(this, GPlayer.class);
                    intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    intent2.putExtra("name", intent.getStringExtra("name"));
                    intent2.putExtra("playURI", intent.getStringExtra("playURI"));
                    startActivity(intent2);
                    break;
                case "video":
                    intent2 = new Intent(this, GPlayer.class);
                    intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    intent2.putExtra("name", intent.getStringExtra("name"));
                    intent2.putExtra("playURI", intent.getStringExtra("playURI"));
                    startActivity(intent2);
                    break;
                case "image":
                    intent2 = new Intent(this, ImageDisplay.class);
                    intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    intent2.putExtra("name", intent.getStringExtra("name"));
                    intent2.putExtra("playURI", intent.getStringExtra("playURI"));
                    intent2.putExtra("isRender", true);
                    startActivity(intent2);
                    break;
                default:
                    intent2 = new Intent(Action.DMR);
                    intent2.putExtra("playpath", intent.getStringExtra("playURI"));
                    sendBroadcast(intent2);
                    break;
            }
        }
        return res;
    }
}
